package HTTPSendIntegrator;

import java.util.ArrayList;
import java.util.Iterator;

public class ForwardReq extends MmsMessage {
	private String forwardReqMessage;
	
	public ForwardReq( ){
		this.mmsMessageType = MMS_MESSAGE_FORWARD_REQ;		
		this.mmsTo = new ArrayList<String>(); 
		this.mmsCC = new ArrayList<String>(); 
		this.mmsBCC = new ArrayList<String>();
		this.mmsParts = new ArrayList<MmsPart>();
	}

	public String integrate(){
		this.forwardReqMessage = "";
		
		if (!this.isMessageIDSet()) return "MessageType not defined";
		if (!this.isTransactionIDSet()) return "transactionID not defined";
		if (!this.isVersionSet()) return "Version not defined";
		if (!this.isMessageSenderSet()) return "Sender not defined";
		if (!this.isContentLocationValue()) return "ContentLocationValue not defined";		
		
		forwardReqMessage += MMS_MESSAGE_TYPE + " " + getMessageType() + NL;
		forwardReqMessage += MMS_TRANSACTION_ID + " " + getTransactionID() + NL;
		forwardReqMessage += MMS_VERSION + " " + this.getMessageID() + NL;
		forwardReqMessage += MMS_FROM + " " + this.getMessageReceivers() + NL;

		String list;
		if (isMessageReceiverSet()){
			Iterator<String> i = getMessageReceivers().iterator();	
			while(i.hasNext()){
				list = i.next();
				forwardReqMessage += MMS_TO + " " + list + NL;				
			}			
		}
		
		if (isMessageCCSet()){
			Iterator<String> i = getMessageCC().iterator();	
			while(i.hasNext()){
				list = i.next();
				forwardReqMessage += MMS_CC+ " " + list + NL;				
			}	
		}
		
		if (isMessageBCCSet()){
			Iterator<String> i = getMessageBCC().iterator();	
			while(i.hasNext()){
				list = i.next();
				forwardReqMessage += MMS_BCC + " " + list + NL;				
			}
		}

		forwardReqMessage += MMS_CONTENT_LOCATION_VALUE + " " + this.getContentLocationValue() + NL;
		
		return this.forwardReqMessage;
	}
}